package com.agree.consts;
/**
 * 交易代码枚举
 * <p>Title: TransServiceCode</p>
 * <p>Description: </p>
 * <p>Company: www.agree.com.cn</p> 
 * @version 1.0
 */
public enum TransServiceCode {

	RADIX("16","解密要转换的进制"),
	JOION_CODE("%","切割需要去掉的字符"),
	LOCK_ACCOUNT("TP200024","电子账户锁定"),
	UNLOCK_ACCOUNT("TP200025","电子账户解锁"),
	BANK_CARD_APPLY("TP200026","2类电子账户配卡申请"),
	UP_GRADE_APPLY("TP200034","3类电子账户升级至2类申请"), 
	DOWN_GRADE_APPLY("TP200032","2类电子账户降级至3类申请"),
	GET_ACCOUNT_BANK_CARD("TP200015","查询电子账户下绑定的卡号"),
	GET_UP_OR_DOWN_GRADE_RESULT("TP200039","查询升降级申请结果"),
	UP_GRADE_ONE_APPLY("TP200044","2，3类卡升级为1类卡申请"),
	ACTIVATE_ACCOUNT("TP200048","电子账户激活"),
	;
	
	
	

	private final String transCode;	//交易代码
	
	private final String transDesc;	//交易代码描述

	TransServiceCode(final String transCode, final String transDesc) {
		this.transCode = transCode;
		this.transDesc = transDesc;
	}
	
	public String getTransCode() {
		return transCode;
	}

	public String getTransDesc() {
		return transDesc;
	}

	//前台发送的加密的交易码，后台解密
	public static String transCodeDecode(String encodeTranCode) {
		//切割
		String[] split = encodeTranCode.split(JOION_CODE.getTransCode());
		StringBuilder sb = new StringBuilder();
		for (int i=split.length-1;i>=0;i--) {
			char valueOf = (char)Integer.valueOf(split[i], Integer.parseInt(RADIX.getTransCode())).intValue();
			sb.append(valueOf);
		}
		return sb.toString();
		
	}
}
